/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jsalon.enumtype;

/**
 *
 * @author Java
 */
public enum Doctype {
    customer(1){
        @Override
        public String caption() {
            return "customer";
        }
        @Override
        public String strValue() {
            return "cust";
        }
    },
    officer(2){
        @Override
        public String caption() {
            return "officer";
        }
        @Override
        public String strValue() {
            return "offi";
        }
    };
    
    private int value;
    public abstract String caption();
    public abstract String strValue();
    
    private Doctype() {
        this.value = 1;
    }
    
    private Doctype(int value) {
        this.value = value;
    }
    public int getVal(){
        return this.value;
    }
    
    public String GetStrValue()
    {
        return this.strValue();
    }
//    public static Doctype fromValue(int value) {  
//        for (Doctype my: Doctype.values()) {  
//            if (my.value == value) {  
//                return my;  
//            }  
//        }  
//        return null;  
//    }  
    
    public static Doctype fromStrValue(String strValue) {  
        for (Doctype my: Doctype.values()) {  
            if (my.strValue() == null ? strValue == null : my.strValue().equals(strValue)) {  
                return my;  
            }  
        }  
        return null;  
    }  
}
